import { _decorator, Component, instantiate, Label, Node, Prefab, UITransform } from 'cc';
import { playerController } from './playerController';
import { pierController } from './pierController';
import { RootController } from './RootController';
const { ccclass, property } = _decorator;

@ccclass('restController')
export class restController extends Component {
    @property(Prefab) pier:Prefab
    start() {

    }

    rest()
    {
        const player = this.node.parent.parent.getChildByName('player')
        const pier0 = instantiate(this.pier)
        const pier1 = instantiate(this.pier)
        const piers = this.node.parent.parent.getChildByName('piersRoot')
        const score = this.node.parent.getChildByName('score')
        const bridges = this.node.parent.parent.getChildByName('bridgesRoot')
        bridges.removeAllChildren();
        score.getComponent(Label).string = '分数:0'
        piers.removeAllChildren();
        piers.addChild(pier0)
        piers.addChild(pier1)
        pier0.setPosition(-606.148,-360)
        pier0.getComponent(UITransform).setContentSize(100,200)
        pier0.getComponent(pierController).IsStart = true;
        pier1.setPosition(-217.358,-360)
        pier1.getComponent(UITransform).setContentSize(140,200)
        pier1.getComponent(pierController).IsStart = true;
        player.setPosition(-539.368,-135.133)
        player.getComponent(playerController).score = 0;
        this.node.parent.parent.getComponent(RootController).isMove = true;
        this.node.active = false;
    }
    update(deltaTime: number) {
        
    }
}


